<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css" ffff>
	-->
	<script type="text/javascript" src="<c:url value="resources/js/jquery-1.8.3.js"/>"></script>
	<script type="text/javascript" src="<c:url value="resources/js/underscore-min.js"/>"></script>
	<script type="text/javascript" src="<c:url value="resources/js/backbone.js"/>"></script>
	<script type="text/javascript" src="<c:url value="resources/js/json2.js"/>"></script>
	<script type="text/javascript" src="<c:url value="resources/js/ge/components.js"/>"></script>

	
	<script type="text/javascript">

		$(document).ready(function(){			
			var AppRouter = Backbone.Router.extend({
		        routes: {
		            "person/:id": "getPerson", // matches http://example.com/#/person/{id}
		            "person/create/": "createPerson" // matches http://example.com/#/person
		        }
		    });
		    // Initiate the router
		    var app_router = new AppRouter;
			var personView = {};
		    
		    //handler for getting a Person record
		    app_router.on('route:getPerson', function (idToFetch) {
		        // Note the variable in the route definition being passed in here  
		        alert('here');
		        var person1 = new Person({id : idToFetch});			
				var result = person1.fetch({
					success : function(){
						//render the view when Person is fetched successfully	
						personView = new PersonEditView({ el: $("#editContainer"), model : person1 });
					},
					error : function(){
						alert("problem");
					}
				});
		    });
		    
		    //handler for creating a new Person record
		    app_router.on('route:createPerson', function (idToFetch) {
		    	//alert("Creating a new Person : " + JSON.stringify(personView.model));
		    	//personView.model.save();
		    	
		    });
		    
		    // Start Backbone history a necessary step for bookmarkable URL's
		    Backbone.history.start();
			

		});
	</script>
  </head>
  
  <body>
  	
  
    This is my JSP22 page. <br>
    <div id="editContainer">h</div>
  </body>
</html>
